package com.example.tool;
import java.util.List;
import com.example.app.MyApplication;
import com.example.netity.order;
import com.example.view.R;
import com.example.view.R.color;
import com.example.view.SecondActivity;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MylisAdapter extends BaseAdapter {
	private SecondActivity mContext = null;
	private List<order> mData;
	private ViewHolder holder;
	public MylisAdapter(SecondActivity lushuUtils, List<order> data) {
		mContext = lushuUtils;
		mData = data;
	}

	@Override
	public int getCount() {
		return mData.size();
	}
	public void setData(List<order> mData) {
		this.mData = mData;
	}
	

	@Override
	public Object getItem(int position) {
		return null;
	}	
	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = LayoutInflater.from(mContext).inflate(R.layout.item_gv1, parent, false);
			holder = new ViewHolder();
			holder.id = (TextView) convertView.findViewById(R.id.gv_id);
			holder.po = (TextView) convertView.findViewById(R.id.gv_po);
			holder.zs = (TextView) convertView.findViewById(R.id.gv_zs);	
			holder.wcs = (TextView) convertView.findViewById(R.id.gv_wcs);
            holder.ll=(LinearLayout)convertView.findViewById(R.id.gv_ll);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}			
		    if(position==MyApplication.index)
		    holder.ll.setBackgroundColor(color.A1A1A1);
		    if(position==MyApplication.index2)
		    {
		     holder.ll.setBackgroundColor(Color.parseColor("#b6d8f3"));
		    }
			holder.id.setText(position+1+"");
			holder.po.setText(mData.get(position).getPo());
			holder.zs.setText(mData.get(position).getNum());
			holder.wcs.setText(mData.get(position).getWnum());
		return convertView;

	}

	static final class ViewHolder {
		TextView id, po, zs,wcs;
		LinearLayout ll;
	}

}
